package org.stu.action;

import com.opensymphony.xwork2.ActionContext;

import java.util.*;

import org.stu.action.base.*;
import org.stu.dto.*;
/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * <br>Copyright (C), 2005-2008, yeeku.H.Lee
 * <br>This program is protected by copyright laws.
 * <br>Program Name:
 * <br>Date: 
 */

public class AddBankRecord extends BaseAction
{
	private BankRecord bankRecord;
	private Bank bank;
	private String action="1";
	private User user;
	private String bankId="1";


	@Override
	public String execute() throws Exception
	{	Map session = ActionContext.getContext().getSession();
		try{
		
			if (action.equals("1")){
				bankRecord.setMoney(0-bankRecord.getMoney());
				
			}
			bank=bankManager.getBankById(Integer.parseInt(bankId));
			user=mgr.getUser((Integer)session.get("userId"));
			bankRecord.setBank(bank);
			bankRecord.setUser(user);
			bankRecord.setDate(new Date());
			bankManager.addBankRecord(bankRecord);
	       
		}catch(Exception e){
			e.printStackTrace();
		}
		 return MAIN;
	}

	

	public String getBankId() {
		return bankId;
	}



	public void setBankId(String bankId) {
		this.bankId = bankId;
	}



	public String getAction() {
		return action;
	}


	public void setAction(String action) {
		this.action = action;
	}



	public BankRecord getBankRecord() {
		return bankRecord;
	}

	public void setBankRecord(BankRecord bankRecord) {
		this.bankRecord = bankRecord;
	}
	
}